package org.csu.jpetstorespringversion.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.csu.jpetstorespringversion.mapper.CategoryMapper;
import org.csu.jpetstorespringversion.mapper.ProductMapper;
import org.csu.jpetstorespringversion.service.CategoryService;
import org.csu.jpetstorespringversion.service.ProductService;
import org.csu.jpetstorespringversion.service.serviceImpl.CategoryServiceImpl;
import org.csu.jpetstorespringversion.service.serviceImpl.ProductServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@Data
//注入依赖
@Repository
//对应数据库中的表名，使用注解的方式
@TableName(value = "category")
public class Category{
    //定义表的主键值
    @TableId(value = "catid", type = IdType.AUTO)
    //类别的ID
    private String catid;
    @TableField(value = "name")
    //类别名字
    private String name;
    //类别描述
    @TableField(value = "descn")
    private String descn;
    @TableField(exist = false)
    private List<Product> productList;

    public List<Product> getProductList(){
        ProductService productService=new ProductServiceImpl();
        List<Product> productList1= productService.getProductListByCategory("BIRDS");
        System.out.println(productList1.size());
        return productList1;
    }

    public String getCatid() {
        return catid;
    }

    public void setCatid(String catid) {
        this.catid = catid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescn() {
        return descn;
    }

    public void setDescn(String descn) {
        this.descn = descn;
    }
}
